#include "Frm09.h"

Frm09::Frm09(HmiApp* app, STTWidget *par, const string& id, const string& desc) : STTPage(app->getRuntime(), par, id, desc) {
	hmiApp = app;
}

Frm09::~Frm09() {
}

void Frm09::onInit() {

}

void Frm09::createParts() {
	setMainArg(0, 0, 1024, 600);
	setMainStyle(0, 0xfffff, 0xffffff, 0, 255, 0, 0xc0c0c0);

	/*----------------------------- Button : wMButton2                   -----------------------------*/
	wMButton2 = new STTButton(p_rt, this, "wMButton2", 0);
	wMButton2->setMainArg(429, 9, 126, 61, false);
	wMButton2->setPressedArg("飞入", 0x0, "文泉驿微米黑", 16, 0);
	wMButton2->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->setReleasedArg("飞入", 0x0, "文泉驿微米黑", 16, 0);
	wMButton2->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton2->onEventHandler(Event::CLICKED, this, (EHandler) & Frm09::wMButton2_clk_cb);

	/*----------------------------- EventTable : wMEventTable1           -----------------------------*/
	wMEventTable1 = new STTTable(p_rt, this, "wMEventTable1");
	wMEventTable1->setMainArg(0, 315, 1024, 168, "LID,序号,80;LTIME,时间,80;EID,事件ID,80;ENME,事件名,80;CLSS,分类,80;WLVL,等级,80;UNME,用户,80;ACTN,动作,80;MEMO,说明,80;EXT1,持续时长,80;EXT2,确认时间,79", 7, false, 2);
	wMEventTable1->setHeadCellStyle(0xf0f0f0, 0xffffff, 0, 1, 0xd0d0d0, 5, 5, 0, 0, 0x0, 16, "文泉驿微米黑", 0);
	wMEventTable1->setSelCellStyle(0x1a2b3, 0xffffff, 0, 1, 0xd0d0d0, 5, 5, 0, 0, 0x0, 16, "文泉驿微米黑", 0);
	wMEventTable1->setDataCellStyle(0xffffff, 0xffffff, 0, 1, 0xd0d0d0, 5, 5, 0, 0, 0x0, 16, "文泉驿微米黑", 0);
	wMEventTable1->setDataSourceOfEvent("", "", false, 0, 99, 15, false);

	/*----------------------------- Panel : wMPanel1                     -----------------------------*/
	wMPanel1 = new STTPanel(p_rt, this, "wMPanel1");
	wMPanel1->setMainArg(9, 489, 1007, 109, 0);
	wMPanel1->setMainStyle(0, 0xffffff, 0xffffff, GradDir::NONE, 255, 1, 0xc0c0c0);

	/*----------------------------- Button : wMButton1                   -----------------------------*/
	wMButton1 = new STTButton(p_rt, wMPanel1, "wMButton1", 0);
	wMButton1->setMainArg(184, 25, 126, 61, false);
	wMButton1->setPressedArg("功能键", 0x0, "文泉驿微米黑", 16, 0);
	wMButton1->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton1->setReleasedArg("功能键", 0x0, "文泉驿微米黑", 16, 0);
	wMButton1->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);

	/*----------------------------- MSwitch : wMMSwitch1                 -----------------------------*/
	wMMSwitch1 = new STTButton(p_rt, wMPanel1, "wMMSwitch1", 2);
	wMMSwitch1->setMainArg(596, 15, 82, 80, false);
	wMMSwitch1->setImg("1", "./images/button_10-1_82X80.gray.svg", "");
	wMMSwitch1->setImg("0", "./images/button_10-0_82X80.svg", "");

	/*----------------------------- Button : wMButton3                   -----------------------------*/
	wMButton3 = new STTButton(p_rt, this, "wMButton3", 0);
	wMButton3->setMainArg(1, 1, 98, 48, false);
	wMButton3->setPressedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setPressedStyle(8, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->setReleasedArg("返回主页", 0x0, "文泉驿微米黑", 16, 0);
	wMButton3->setReleasedStyle(5, 255, 0xebebeb, 0x999999, 1, 1, 0x999999, 1, 0xebebeb);
	wMButton3->bindOpenFormHandler(Event::CLICKED, "Frm03", PageMode::NEWWIN, NULL);

	/*called after widget created.*/

	return; //createParts END
}
//飞入
//static void valuecb(void* obj, int32_t v) {
//	Frm09* widget = (Frm09*)obj;
//	widget->setY(v);
//}
////渐显
//static void valuecb2(void* obj, int32_t v) {
//	Frm09* widget = (Frm09*)obj;
//	for(int i=0;i<widget->getChildCnt();i++)
//		widget->getChildWidget(i)->getStyle()->p_bg->setOpa(v);
//	widget->getStyle()->p_bg->setOpa(v);
//}

void Frm09::onLoad() {
	//this->getStyle()->p_anim->doAnim(this,-Util::getScrSize().w,0,1000,valuecb,NULL,1);
//	this->getStyle()->p_anim->doAnim(this,0,255,3000,valuecb2,NULL,1);
}

bool Frm09::onClosing() {
	return true;
}

void Frm09::onDispose() {

}
static void valuecb(void* obj, int32_t v) {
	STTWidget* widget = (STTWidget*)obj;
	widget->setY(v);
}
void Frm09::wMButton2_clk_cb(uint16_t code, LvEvent e) {
	/*wMButton2（功能键）的点击事件*/
	wMPanel1->getStyle()->p_anim->doAnim(wMPanel1, Util::getScrSize().h, 391, 2000, valuecb, NULL, 1);
}
